package com.example.contorller;

import com.example.bean.Leaveword;
import com.example.repository.LeavewordRepository;
import com.example.utils.ResultMsg;
import com.example.utils.ResultStatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("leaveword")
public class LeavewordController {
    @Autowired
    private LeavewordRepository leavewordRepository;

    @Modifying
    @RequestMapping("/addleaveword")
    public Object addLeaveWord(@RequestBody Leaveword leavewordEntity) {
        leavewordRepository.save(leavewordEntity);
        ResultMsg resultMsg = new ResultMsg(ResultStatusCode.OK.getErrcode(), ResultStatusCode.OK.getErrmsg(), leavewordEntity);


        return resultMsg;
    }
}
